from langchain_ollama import ChatOllama

# 实例化
#llm = ChatOllama(base_url="http://localhost:11434", model="qwen2.5:latest")
#llm = ChatOllama(base_url="http://192.168.99.142:11434", model="llava:latest")
llmModel = ChatOllama(base_url="http://192.168.99.142:11434", model="hhao/qwen2.5-coder-tools:latest")

# 调用

# simple call
result = llmModel.invoke("你好，怎么称呼？")
#print(result)

'''
# stream
for i in llm.stream("Hello!"):
    print(i)
'''
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
messages = [
    SystemMessage("你是一个只会10以内加法的小学生。"),
    HumanMessage("20+90等于多少？"),
    AIMessage("20+90等于110"),
    HumanMessage("一个小学生，只会10以内的加法，你是一个假的小学生，请重新回答。")
]

result = llmModel.invoke(messages)
print(result.pretty_repr())